package com.webapp.manager.impl;

import java.util.List;

import com.webapp.basedata.Food;
import com.webapp.basedata.Type;
import com.webapp.dao.impl.FoodDaoImpl;
import com.webapp.manager.FoodManager;

public class FoodManagerImpl implements FoodManager {

	@Override
	public void addFood(Type type, String name, double price, String introduce) {
		Food food = new Food();
		food.setType(type);
		food.setName(name);
		food.setPrice(price);
		food.setIntroduce(introduce);
		new FoodDaoImpl().addFood(food);
	}

	@Override
	public Food findFoodById(int id) {
		return new FoodDaoImpl().findFoodById(id);
	}

	@Override
	public void modifyFood(int id, Type type, String name, double price,
			String introduce) {
		FoodDaoImpl daoImpl = new FoodDaoImpl();
		Food food = daoImpl.findFoodById(id);
		food.setIntroduce(introduce);
		food.setName(name);
		food.setType(type);
		food.setPrice(price);
		daoImpl.modifyFood(food);
	}

	@Override
	public void deleteFoodById(int id) {
		new FoodDaoImpl().deleteFood(id);

	}

	@Override
	public List<Food> seachFoodsByType(int typeId) {
		return new FoodDaoImpl().findFoodByType(typeId);
	}

	@Override
	public List<Food> findFoods() {
		FoodDaoImpl daoImpl = new FoodDaoImpl();
		return daoImpl.findFoods();
	}

}
